<?xml version="1.0" encoding="UTF-8"?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	template="/forms/default/template.xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:web="http://www.web.com.br/jsf/webutils">

	<ui:define name="breadcrumbEvento">

		<web:breadcrumb urlIndex="/index.xhtml">

			<p:menuitem value="#{messages['navegacao.meuseventos']}"
				action="#{meusEventosUI.prepareSearch}" />


			<p:menuitem value="#{messages['navegacao.editarevento']}"
				action="/forms/eventos/eventoCadastrar.xhtml" />

			<p:menuitem value="#{messages['navegacao.editarevento.submissoes']}" />

		</web:breadcrumb>

	</ui:define>

	<ui:define name="contentEvento">

		<web:searchOptionsPanel id="searchSubmissao"
			backingBean="#{submissaoUI}" showOnly="true">

			<ui:define name="searchContent">

				<h:panelGrid columns="2">

					<h:panelGroup rendered="#{web:nvl(rendered, true)}">
						<div style="float: left; width: 120px; text-align: right;">
							<h:outputText id="labelEvento"
								value="#{messages['label.evento']}:" style="font-size: 14px;" />
						</div>
					</h:panelGroup>

					<h:panelGroup rendered="#{web:nvl(rendered, true)}">
						<div style="float: left; width: 360px; text-align: left;">
							<h:outputText id="inputEvento"
								value="#{submissaoUI.filter.evento.nome}"
								style="font-size: 14px; font-weight: bold;" />
						</div>
					</h:panelGroup>

				</h:panelGrid>

			</ui:define>

		</web:searchOptionsPanel>

		<web:searchResultDataTable id="gridSubmissoes"
			backingBean="#{submissaoUI}" style="margin: 5px;">

			<p:column style="text-align: center; width: 70px;">

				<f:facet name="header">
					#{messages['global.opcoes.fieldset']}
				</f:facet>

				<p:commandButton id="cbtnEditC" value="#{null}"
					icon="#{messages['global.operations.edit.icon']}"
					title="#{messages['global.operations.edit']}"
					rendered="#{submissaoUI.isPresidente(dataTableItem)}"
					action="#{submissaoUI.prepareEdit}" immediate="true" ajax="false"
					style="margin-right: 5px;">

					<f:setPropertyActionListener value="#{dataTableItem}"
						target="#{submissaoUI.bean}" />

				</p:commandButton>

			</p:column>

			<p:column style="text-align: center; width: 50px;">
				<f:facet name="header">
					#{messages['label.detalhes']}
				</f:facet>

				<p:rowToggler />
			</p:column>

			<p:rowExpansion>

				<!-- Dados de quando o Usuário for o presidente do comite que recebeu a submissão -->

				<h:outputText value="#{messages['label.arquivos']}:"
					style="font-weight: bold;"
					rendered="#{submissaoUI.isPresidente(dataTableItem)}" />

				<p:dataTable widgetVar="dataTableDetailSubmissaoArquivos"
					id="detailDataTableSubmissaoArquivos"
					value="#{submissaoUI.arquivosSubmissao(dataTableItem)}"
					var="dataTableDetailItem" rows="100" paginatorAlwaysVisible="false"
					emptyMessage="#{messages['global.msg.search_not_found']}"
					rendered="#{submissaoUI.isPresidente(dataTableItem)}">

					<p:column style="width: 200px;">
						<f:facet name="header">
							<h:outputText value="#{messages['label.id']}" />
						</f:facet>

						<h:outputText value="#{dataTableDetailItem.id}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{messages['label.arquivo']}" />
						</f:facet>

						<h:commandLink value="#{dataTableDetailItem.arquivoRelativo}">
							<f:setPropertyActionListener value="#{dataTableDetailItem}"
								target="#{submissaoUI.submissaoArquivoDownload}" />
							<p:fileDownload value="#{submissaoUI.arquivoDownload}"/>
						</h:commandLink>
					</p:column>

					<p:column style="width: 150px;">
						<f:facet name="header">
							<h:outputText value="#{messages['label.tamanho']}" />
						</f:facet>

						<h:outputText value="#{dataTableDetailItem.tamanho} bytes" />
					</p:column>

				</p:dataTable>

				<web:clear />

				<h:outputText value="#{messages['label.avaliadores']}:"
					style="font-weight: bold;"
					rendered="#{submissaoUI.isPresidente(dataTableItem)}" />

				<p:dataTable widgetVar="dataTableDetailPresidente"
					id="detailDataTablePresidente"
					value="#{submissaoUI.avaliacoesSubmissao(dataTableItem)}"
					var="dataTableDetailItem" rows="100" paginatorAlwaysVisible="false"
					emptyMessage="#{messages['global.msg.search_not_found']}"
					rendered="#{submissaoUI.isPresidente(dataTableItem)}">

					<p:column style="width: 200px;">
						<f:facet name="header">
							<h:outputText value="#{messages['label.id']}" />
						</f:facet>

						<h:outputText value="#{dataTableDetailItem.id}" />
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{messages['label.avaliador']}" />
						</f:facet>

						<h:outputText
							value="#{dataTableDetailItem.comiteMembro.participante.cadastro.razaoSocial}" />
					</p:column>

					<p:column style="width: 150px;">
						<f:facet name="header">
							<h:outputText value="#{messages['label.status']}" />
						</f:facet>

						<h:outputText value="#{dataTableDetailItem.status}" />
					</p:column>

				</p:dataTable>

				<!-- *** -->

				<web:clear />
				
				<!-- Dados de quando o Usuário for o membro do comite que vai avaliar -->
				
				<h:outputText value="#{messages['label.arquivos']}:"
					style="font-weight: bold;"
					rendered="#{!submissaoUI.isPresidente(dataTableItem)}" />

				<p:dataTable widgetVar="dataTableDetailAvaliador"
					id="detailDataTableAvaliador"
					value="#{submissaoUI.avaliacoesSubmissao(dataTableItem)}"
					var="dataTableDetailItem" rows="100" paginatorAlwaysVisible="false"
					emptyMessage="#{messages['global.msg.search_not_found']}"
					rendered="#{!submissaoUI.isPresidente(dataTableItem)}">

					<p:column style="text-align: center; width: 100px;">
						<f:facet name="header">
							<h:outputText value="#{messages['global.opcoes.fieldset']}" />
						</f:facet>

						<p:commandButton id="#{id}cbtnEditC" value="#{null}"
							icon="#{messages['global.operations.edit.icon']}"
							title="#{messages['global.operations.edit']}"
							action="#{submissaoAvaliacaoUI.prepareEdit}" immediate="true"
							ajax="true" style="margin-right: 5px;">

							<f:setPropertyActionListener value="#{dataTableDetailItem}"
								target="#{submissaoAvaliacaoUI.bean}" />

						</p:commandButton>
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="#{messages['label.arquivos']}" />
						</f:facet>

						<ul>
							<ui:repeat value="#{submissaoUI.arquivosSubmissao(dataTableItem)}"
								var="dataRepeatItem">
								<li>
									<h:commandLink value="#{dataRepeatItem.arquivoRelativo}">
										<f:setPropertyActionListener value="#{dataRepeatItem}"
											target="#{submissaoUI.submissaoArquivoDownload}" />
										<p:fileDownload value="#{submissaoUI.arquivoDownload}"/>
									</h:commandLink>
								</li>
							</ui:repeat>
						</ul>
					</p:column>

					<p:column style="width: 150px;">
						<f:facet name="header">
							<h:outputText value="#{messages['label.status']}" />
						</f:facet>

						<h:outputText value="#{dataTableDetailItem.status}" />
					</p:column>

				</p:dataTable>
		
				<!-- *** -->

			</p:rowExpansion>

			<p:column style="text-align: center; width: 50px;">
				<f:facet name="header">
					#{messages['label.avaliadores']}
				</f:facet>

				<p:commandButton id="avalidoresLnk"
					action="#{submissaoAvaliacaoUI.prepareSearch}" ajax="true"
					value="#{messages['label.editaravaliadores']}"
					style="font-size: 12px; margin-bottom: 5px;"
					rendered="#{submissaoUI.isPresidente(dataTableItem)}">

					<f:setPropertyActionListener value="#{dataTableItem}"
						target="#{submissaoAvaliacaoUI.filter.submissao}" />

				</p:commandButton>

			</p:column>

			<web:column id="submissoesColumnTema"
				title="#{messages['label.tema']}">
				<h:outputText style="text-align: center; display: block;"
					value="#{dataTableItem.tema.descricao}" />
			</web:column>

			<web:column id="submissoesColumnParticipante"
				title="#{messages['label.enviadopor']}">
				<h:outputText style="text-align: center; display: block;"
					value="#{dataTableItem.participante.cadastro.razaoSocial}" />
			</web:column>

			<web:column id="submissoesColumnPresidente"
				title="#{messages['label.status']}">
				<h:outputText style="text-align: center; display: block;"
					value="#{dataTableItem.status}" />
			</web:column>

		</web:searchResultDataTable>

	</ui:define>

</ui:composition>